<template>
  <div class="user-management-container">
    <div class="page-header">
      <h2>用户管理</h2>
      <div class="header-actions">
        <button class="btn-primary">添加用户</button>
        <button class="btn-secondary">批量操作</button>
      </div>
    </div>
    
    <div class="filter-section">
      <div class="search-box">
        <input type="text" placeholder="搜索用户..." class="search-input" />
        <button class="search-btn">🔍</button>
      </div>
      <div class="filter-options">
        <select class="filter-select">
          <option>全部角色</option>
          <option>超级管理员</option>
          <option>知识库管理员</option>
          <option>普通用户</option>
        </select>
        <select class="filter-select">
          <option>全部状态</option>
          <option>活跃</option>
          <option>禁用</option>
        </select>
      </div>
    </div>
    
    <div class="user-table">
      <table>
        <thead>
          <tr>
            <th><input type="checkbox" /></th>
            <th>用户名</th>
            <th>用户ID</th>
            <th>角色</th>
            <th>状态</th>
            <th>注册时间</th>
            <th>最后登录</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td><input type="checkbox" /></td>
            <td>张三</td>
            <td>U001</td>
            <td><span class="role admin">超级管理员</span></td>
            <td><span class="status active">活跃</span></td>
            <td>2024-01-01</td>
            <td>2024-01-15</td>
            <td>
              <button class="btn-sm">编辑</button>
              <button class="btn-sm">禁用</button>
            </td>
          </tr>
          <tr>
            <td><input type="checkbox" /></td>
            <td>李四</td>
            <td>U002</td>
            <td><span class="role manager">知识库管理员</span></td>
            <td><span class="status active">活跃</span></td>
            <td>2024-01-02</td>
            <td>2024-01-14</td>
            <td>
              <button class="btn-sm">编辑</button>
              <button class="btn-sm">禁用</button>
            </td>
          </tr>
          <tr>
            <td><input type="checkbox" /></td>
            <td>王五</td>
            <td>U003</td>
            <td><span class="role user">普通用户</span></td>
            <td><span class="status inactive">禁用</span></td>
            <td>2024-01-03</td>
            <td>2024-01-10</td>
            <td>
              <button class="btn-sm">编辑</button>
              <button class="btn-sm">启用</button>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    
    <div class="pagination">
      <button class="btn-sm">上一页</button>
      <span class="page-info">第 1 页，共 5 页</span>
      <button class="btn-sm">下一页</button>
    </div>
  </div>
</template>

<script setup>
// 用户管理组件逻辑
</script>

<style scoped>
.user-management-container {
  padding: 0;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h2 {
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 1rem;
}

.btn-primary {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
}

.filter-section {
  background: white;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.search-box {
  display: flex;
  align-items: center;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  overflow: hidden;
  flex: 1;
  max-width: 300px;
}

.search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  outline: none;
}

.search-btn {
  background: #4f46e5;
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  cursor: pointer;
}

.filter-options {
  display: flex;
  gap: 1rem;
}

.filter-select {
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background: white;
  font-size: 0.875rem;
}

.user-table {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  margin-bottom: 2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: #f9fafb;
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
}

td {
  padding: 1rem;
  border-bottom: 1px solid #f3f4f6;
  color: #6b7280;
}

.role {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.role.admin {
  background: #fef2f2;
  color: #dc2626;
}

.role.manager {
  background: #fef3c7;
  color: #92400e;
}

.role.user {
  background: #dcfce7;
  color: #166534;
}

.status {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.status.active {
  background: #dcfce7;
  color: #166534;
}

.status.inactive {
  background: #fef2f2;
  color: #dc2626;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  margin: 0 0.25rem;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.75rem;
}

.btn-sm:hover {
  background: #f9fafb;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.page-info {
  color: #6b7280;
  font-size: 0.875rem;
}

@media (max-width: 768px) {
  .filter-section {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-box {
    max-width: none;
  }
  
  .filter-options {
    flex-direction: column;
  }
}
</style>
